package com.atguigu.jxc.controller;/*
 *@author 尹凯瑞
 *@date 2020/12/3 11:25
 */

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.Customer;
import com.atguigu.jxc.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("customer")
public class CustomerController {

    @Autowired
    private CustomerService customerService;

    //客户列表分页查询（带名称模糊查询）http://localhost:8080 /customer/list
    @RequestMapping("/list")
    public Map<String,Object> list(Integer page, Integer rows, String  customerName){
        return customerService.listCustomer(page,rows,customerName);
    }
    //客户添加或修改 http://localhost:8080/ customer/save?customerId=1
    @RequestMapping("/save")
    public ServiceVO saveOrUpdate(Customer customer){
        return customerService.saveOrUpdate(customer);
    }
    //删除客户，支持批量删除 http://localhost:8080/customer/delete
    @RequestMapping("/delete")
    public ServiceVO deleteCustomer(String ids){
        return customerService.deleteCustomer(ids);
    }

}
